SELECT last_name, employee_id
	FROM employee
	INNER JOIN job 
	ON (employee.job_id = job.job_id AND "function" = 'SALESPERSON')
	WHERE ((SELECT COUNT(*)
				FROM sales_order
				INNER JOIN customer
				ON (YEAR(order_date) = 1989 AND sales_order.customer_id = customer.customer_id)
				GROUP BY salesperson_id
				HAVING salesperson_id = employee_id) > 3
		AND (SELECT SUM(total)
			FROM sales_order
			INNER JOIN customer
			ON (sales_order.customer_id = customer.customer_id AND YEAR(order_date) = 1989)
			WHERE (customer.salesperson_id = employee_id)
			GROUP BY customer.salesperson_id) > 5000)